<!doctype html>

<html>
<head>
  <link rel="shortcut icon" href="static/images/favicon.ico" type="image/x-icon">
  <title>mockmessageevent.js (Closure Library API Documentation - JavaScript)</title>
  <link rel="stylesheet" href="static/css/base.css">
  <link rel="stylesheet" href="static/css/doc.css">
  <link rel="stylesheet" href="static/css/sidetree.css">
  <link rel="stylesheet" href="static/css/prettify.css">

  <script>
     var _staticFilePath = "static/";
     var _typeTreeName = "goog";
     var _fileTreeName = "Source";
  </script>

  <script src="static/js/doc.js">
  </script>


  <meta charset="utf8">
</head>

<body onload="grokdoc.onLoad();">

<div id="header">
  <div class="g-section g-tpl-50-50 g-split">
    <div class="g-unit g-first">
      <a id="logo" href="index.html">Closure Library API Documentation</a>
    </div>

    <div class="g-unit">
      <div class="g-c">
        <strong>Go to class or file:</strong>
        <input type="text" id="ac">
      </div>
    </div>
  </div>
</div>

<div class="clear"></div>

<h2><a href="local_closure_goog_testing_messaging_mockmessageevent.js.html">mockmessageevent.js</a></h2>

<pre class="prettyprint lang-js">
<a name="line1"></a>// Copyright 2010 The Closure Library Authors. All Rights Reserved.
<a name="line2"></a>//
<a name="line3"></a>// Licensed under the Apache License, Version 2.0 (the &quot;License&quot;);
<a name="line4"></a>// you may not use this file except in compliance with the License.
<a name="line5"></a>// You may obtain a copy of the License at
<a name="line6"></a>//
<a name="line7"></a>//      http://www.apache.org/licenses/LICENSE-2.0
<a name="line8"></a>//
<a name="line9"></a>// Unless required by applicable law or agreed to in writing, software
<a name="line10"></a>// distributed under the License is distributed on an &quot;AS-IS&quot; BASIS,
<a name="line11"></a>// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
<a name="line12"></a>// See the License for the specific language governing permissions and
<a name="line13"></a>// limitations under the License.
<a name="line14"></a>
<a name="line15"></a>/**
<a name="line16"></a> * @fileoverview A simple mock class for imitating HTML5 MessageEvents.
<a name="line17"></a> *
<a name="line18"></a> */
<a name="line19"></a>
<a name="line20"></a>goog.provide(&#39;goog.testing.messaging.MockMessageEvent&#39;);
<a name="line21"></a>
<a name="line22"></a>goog.require(&#39;goog.events.BrowserEvent&#39;);
<a name="line23"></a>goog.require(&#39;goog.events.EventType&#39;);
<a name="line24"></a>goog.require(&#39;goog.testing.events&#39;);
<a name="line25"></a>
<a name="line26"></a>
<a name="line27"></a>
<a name="line28"></a>/**
<a name="line29"></a> * Creates a new fake MessageEvent.
<a name="line30"></a> *
<a name="line31"></a> * @param {*} data The data of the message.
<a name="line32"></a> * @param {string=} opt_origin The origin of the message, for server-sent and
<a name="line33"></a> *     cross-document events.
<a name="line34"></a> * @param {string=} opt_lastEventId The last event ID, for server-sent events.
<a name="line35"></a> * @param {Window=} opt_source The proxy for the source window, for
<a name="line36"></a> *     cross-document events.
<a name="line37"></a> * @param {Array.&lt;MessagePort&gt;=} opt_ports The Array of ports sent with the
<a name="line38"></a> *     message, for cross-document and channel events.
<a name="line39"></a> * @extends {goog.testing.events.Event}
<a name="line40"></a> * @constructor
<a name="line41"></a> * @final
<a name="line42"></a> */
<a name="line43"></a>goog.testing.messaging.MockMessageEvent = function(
<a name="line44"></a>    data, opt_origin, opt_lastEventId, opt_source, opt_ports) {
<a name="line45"></a>  goog.testing.messaging.MockMessageEvent.base(
<a name="line46"></a>      this, &#39;constructor&#39;, goog.events.EventType.MESSAGE);
<a name="line47"></a>
<a name="line48"></a>  /**
<a name="line49"></a>   * The data of the message.
<a name="line50"></a>   * @type {*}
<a name="line51"></a>   */
<a name="line52"></a>  this.data = data;
<a name="line53"></a>
<a name="line54"></a>  /**
<a name="line55"></a>   * The origin of the message, for server-sent and cross-document events.
<a name="line56"></a>   * @type {?string}
<a name="line57"></a>   */
<a name="line58"></a>  this.origin = opt_origin || null;
<a name="line59"></a>
<a name="line60"></a>  /**
<a name="line61"></a>   * The last event ID, for server-sent events.
<a name="line62"></a>   * @type {?string}
<a name="line63"></a>   */
<a name="line64"></a>  this.lastEventId = opt_lastEventId || null;
<a name="line65"></a>
<a name="line66"></a>  /**
<a name="line67"></a>   * The proxy for the source window, for cross-document events.
<a name="line68"></a>   * @type {Window}
<a name="line69"></a>   */
<a name="line70"></a>  this.source = opt_source || null;
<a name="line71"></a>
<a name="line72"></a>  /**
<a name="line73"></a>   * The Array of ports sent with the message, for cross-document and channel
<a name="line74"></a>   * events.
<a name="line75"></a>   * @type {Array.&lt;!MessagePort&gt;}
<a name="line76"></a>   */
<a name="line77"></a>  this.ports = opt_ports || null;
<a name="line78"></a>};
<a name="line79"></a>goog.inherits(
<a name="line80"></a>    goog.testing.messaging.MockMessageEvent, goog.testing.events.Event);
<a name="line81"></a>
<a name="line82"></a>
<a name="line83"></a>/**
<a name="line84"></a> * Wraps a new fake MessageEvent in a BrowserEvent, like how a real MessageEvent
<a name="line85"></a> * would be wrapped.
<a name="line86"></a> *
<a name="line87"></a> * @param {*} data The data of the message.
<a name="line88"></a> * @param {string=} opt_origin The origin of the message, for server-sent and
<a name="line89"></a> *     cross-document events.
<a name="line90"></a> * @param {string=} opt_lastEventId The last event ID, for server-sent events.
<a name="line91"></a> * @param {Window=} opt_source The proxy for the source window, for
<a name="line92"></a> *     cross-document events.
<a name="line93"></a> * @param {Array.&lt;MessagePort&gt;=} opt_ports The Array of ports sent with the
<a name="line94"></a> *     message, for cross-document and channel events.
<a name="line95"></a> * @return {!goog.events.BrowserEvent} The wrapping event.
<a name="line96"></a> */
<a name="line97"></a>goog.testing.messaging.MockMessageEvent.wrap = function(
<a name="line98"></a>    data, opt_origin, opt_lastEventId, opt_source, opt_ports) {
<a name="line99"></a>  return new goog.events.BrowserEvent(
<a name="line100"></a>      new goog.testing.messaging.MockMessageEvent(
<a name="line101"></a>          data, opt_origin, opt_lastEventId, opt_source, opt_ports));
<a name="line102"></a>};
</pre>


</body>
</html>
